<?php
/**
 * @orm tablename wb_banners
 */
class WbSiteBanner {
	
	/**
	 * @orm char(255)
	 */
	public $name;
	/**
	 * @orm has parent WbSite inverse banners
	 */
	public $parent;
	/**
	 * @orm char(255)
	 */
	public $location;
	/**
	 * @orm char(255)
	 */
	public $link;
	/**
	 * @orm plugin DomArMedia({autoRename=1r,allowedExtensions={gif,jpg,jpeg,png,swf}})
	 */
	public $banner;
	/**
	 * @orm longtext
	 */
	public $code;
	/**
	 * @orm boolean
	 */
	public $active = true;
	
	public function getBannerHtml() {
		if( trim($this->code) ) {
			$html = $this->code;
			
		} else {
			//$locations = self::getLocations();
			$html = $this->banner->toHtml( 
				array(
					//'width'=>$locations[$this->location]['defaultWidth'], 
					//'height'=>$locations[$this->location]['defaultHeight'], 
					'target'=>'_blank', 
					'link'=> $this->link ? $this->link : NULL, 
				) 
			);
		}
		return $html;
	}
}